﻿@using Presentation.Web.Admin
@model Application.Admin.Dto.SightDto
@{
    var sightAreaService = Presentation.Web.Admin.PreAdminEngine
        .Resolve<Application.Admin.Sight.ISightPointAreaService>();
    var allArea = sightAreaService.GetList();

    var sightClassService = Presentation.Web.Admin.PreAdminEngine
        .Resolve<Application.Admin.Sight.ISightPointClassService>();
    var allClass = sightClassService.GetList().ToList();
}
@using (Ajax.BeginForm("detail", "sight", new AjaxOptions
{
    OnBegin = "checkedForm",
    HttpMethod = "post",
    OnFailure = "AjaxOptionsEditFailure",
    OnSuccess = "AjaxOptionsEditSuccess"
}))
{
    @Html.ValidationSummary(true)
    <fieldset class="module width_full">
        <div style="width: 45%; float: left; margin-right: 2%;">
            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Remark)
            </div>
            <div class="editor-field">
                @Html.TextAreaFor(model => model.Remark, new { rows = 13, @class = "text-box", style = "padding:5px 2px;" })
                @Html.ValidationMessageFor(model => model.Remark)
            </div>
        </div>
        <div style="width: 45%; float: right; margin-left: 2%;">
            <div class="editor-label">
                @Html.LabelFor(model => model.SightArea.Name)
            </div>
            <div class="editor-field">
                <select id="AreaId" name="AreaId">
                    <option value="0">----请选择----</option>
                    @{
    foreach (var item in allArea)
    {
                        <option value="@(item.Id)"  @(Model.AreaId == item.Id ? "selected = 'selected'" : "")   >@(item.Name)</option>
    }
                    }
                </select>
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.SightClass.Name)
            </div>
            <div class="editor-field">
                <select id="ClassId" name="ClassId">
                    <option value="0">----请选择----</option>
                    @{
    foreach (var item in allClass)
    {
                        <option value="@(item.Id)"  @(Model.ClassId == item.Id ? "selected = 'selected'" : "")   >@(item.Name)</option>
    }
                    }
                </select>
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Lat)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Lat)
                @Html.ValidationMessageFor(model => model.Lat)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Lon)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Lon)
                @Html.ValidationMessageFor(model => model.Lon)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.VouchNum)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.VouchNum)
                @Html.ValidationMessageFor(model => model.VouchNum)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Address)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Address)
                @Html.ValidationMessageFor(model => model.Address)
            </div>
        </div>
        <div style="display: none;">
            @Html.HiddenFor(model => model.AreaId)
            @Html.HiddenFor(model => model.UserId)
            @Html.HiddenFor(model => model.IsAud)
            @Html.HiddenFor(model => model.IsDelete)
            @Html.HiddenFor(model => model.IsVouch)
            @Html.HiddenFor(model => model.IsTop)
            @Html.HiddenFor(model => model.AudTime)
            @Html.HiddenFor(model => model.DeleteTime)
            @Html.HiddenFor(model => model.VouchTime)
            @Html.HiddenFor(model => model.TopTime)
            @Html.HiddenFor(model => model.Id)
            @Html.HiddenFor(model => model.State)
            @Html.HiddenFor(model => model.SortNum)
            @Html.HiddenFor(model => model.UserName)
            @Html.HiddenFor(model => model.AddTime)
            @Html.HiddenFor(model => model.IpAddress)
        </div>
    </fieldset> 
    <p>
        @{
    if (Html.HasUiPermission(this.ViewContext, "detail"))
    {
            <input type="submit" value="修改" class="alt_btn module_margin" />
            @Html.GoBackPre("t-button")
    }
        }
    </p>
}
<script type="text/javascript">
    function checkedForm() {
        var name = $('#Name');
        if (name.val() == '') {
            alert('景点名不能为空');
            name.focus();
            return false;
        }
    }
</script>
